#!/usr/bin/env perl

use lib ($ENV{RLWRAP_FILTERDIR} or ".");
use RlwrapFilter;
use strict;

my $N = 0;


my $filter = new RlwrapFilter;
my $name = $filter -> name;

$filter -> help_text("Usage: rlwrap -z $name <command>\n".
		     "replace prompt by simple counter\n".
		     "(demonstrates some simple prompt-munging techniques)");

$filter -> prompt_handler (\&munge_prompt);

$filter -> run;


sub munge_prompt {
  my ($prompt) = @_;
  if ($filter -> previous_tag == TAG_OUTPUT) {
    $N++;
    return "prompt $N > ";
  } else {
    return $prompt;
  }
}
